<?php 

namespace Admin\Controller;
use Think\Controller;
use Lib\Selfclass;
class ArticleController extends ACommonController {
    public function index(){
        $Articledb  = M('article')->select();
        $Articledb['catename'] = M('category')->select();
        // show($Articledb);
        $this->assign('Articledb',$Articledb);
    


   	$this->display();
    }
    public function insertArticle(){
    		if(IS_POST){
    			
    		}
    		// 所有顶级分类
    			 $this->assign('Catedb',D('Category')->where('pid=0')->findall());

    	$this->display();
    }
    public function editArticle(){
        //查出当前页面的相关信息
        $thiscate = M('category')->where('cid='.I('cid'))->find();
        //show($thiscate);
        $this->assign('thiscate',$thiscate);
         //查出所有的分类 
         $cnamedb = M('category')->field('cname','cid')->select();
         $this->assign('cnamedb',$cnamedb);

         // show($cnamedb);
        $this->display();
    }
    public function delCate(){
        $result = M('category')->where('cid='.I('cid'))->delete();
        if($result!=="false"){
            $this->success('删除成功',U('Category/index'));

        }else{
            $this->error('删除出错');
        }
    }
    /**
     * [creatPingying 生成拼音]
     * @return [type] [description]
     */
    public function AjaxCreatPingying(){
    	if(IS_Ajax){
    		$title = $_POST['title'];
            //树类无限分类处理
    		$ping = new \Org\Util\Stringhd();
    		$titleping = $ping->pinyin($title);
    		return $titleping;
    	}

    }


}